home *** CD-ROM | disk | FTP | other *** search
- ;This is a procedure callable from QBasic to draw a window on the screen.
- ;The left & right column, top & bottom row, attribute & frame type, and explode
- ;& shadow parameters are passed from Basic in that order as 4 words.
-
- Name Makewind ;Name used at link time
- Public Makewind ;Only module name is public
-
- Makewind: org 0 ;So can be linked
-
- Spc equ 20h
- Period equ 800 ;Initial period for sound
-
- jmp short Getpara ;Get parameters
-
- Parameters:
- Explode db 1 ;1=>explode window from center
- Shadow db 1 ;1=>shadow window when done
- Attr db 37 ;Attribute byte for window
- Frame db 1 ;Frame type; 0=>line, 1=>double line
- Urow db 2 ;Upper row of window
- Lrow db 23 ;Lower row of window
- Lcol db 10 ;Left column of window
- Rcol db 70 ;Right column of window
- Freq dw Period ;Count for sound
- Row1 db ? ;Current upper row
- Row2 db ? ;Current lower row
- Col1 db ? ;Current left column
- Col2 db ? ;Current right column
- Mcol db ? ;Difference between Lcol and Rcol
- Mrow db ? ;Difference between Urow and Lrow
- Flag db 0 ;0=>no growth
- Rows db ? ;Number of rows to do
- Vpage db ? ;Current video page
- Vidmem dw 0B800h ;Video page 1 segment
- Msg1: db 'Not in a color mode now.$' ;Error message
- Table: ;Table of box chars
- db '┌─┐│ │└─┘' ;Single line chars
- db '╔═╗║ ║╚═╝' ;Double line chars
- db '╒═╕│ │╘═╛' ;Double horiz, single vert
- db '╓─╖║ ║╙─╜' ;Single horiz, double vert
-
- Getpara: ;Get parameters from stack
- push bp
- mov bp,sp
- push ds
- push es
- push cs ;es=cs
- pop es
- cld ;Set to inc si & di
- add bp,6 ;Point to 1st parameter address
- mov cx,4 ;4 parameters to get
- mov di,Parameters ;Point to parameter storage area
- A0: mov si,[bp] ;Get address of parameter
- movsw ;Get the parameter
- add bp,2 ;Point to next passed parameter address
- loop A0 ;Get all 4 parameters
- push cs ;ds=cs
- pop ds
-
- ;Get current video mode and page
- mov ah,15 ;Get current video mode
- int 10h
- mov Vpage,bh ;Save page
- cmp al,2 ;Mode 2?
- je Color ;Yes
- cmp al,3 ;Mode 3?
- je Color ;Yes
- mov dx,Msg1 ;No, print message
- mov ah,9
- int 21h
- Exit: ;Return to Basic
- pop es
- pop ds
- pop bp
- retf 8
-
- Color: ;Find video memory.
- mov bl,0 ;bx=page offset
- add bx,Vidmem ;Add page 0 address
- mov Vidmem,bx ;Save it
- mov es,bx ;Set for dest segment
-
- ;Find Row1, Row2, Col1, Col2, Mcol, and Rcol
- mov al,Lrow
- sub al,Urow
- shr al,1
- mov Mrow,al
-
- mov al,Rcol
- sub al,Lcol
- shr al,1
- mov Mcol,al
-
- mov al,Urow
- add al,Mrow
- mov Row1,al
-
- mov al,Lrow
- sub al,Mrow
- mov Row2,al
-
- mov al,Lcol
- add al,Mcol
- mov Col1,al
-
- mov al,Rcol
- sub al,Mcol
- mov Col2,al
- ;See if window should explode
- cmp Explode,0 ;Explode?
- je Nosound ;No
- in al,61h ;Enable speaker
- or al,3
- out 61h,al
- jmp short Grow
- Nosound: mov al,Urow ;Set to max dimensions
- mov Row1,al
- mov al,Lrow
- mov Row2,al
- mov al,Lcol
- mov Col1,al
- mov al,Rcol
- mov Col2,al
-
- Grow: ;Grow the window from its center point found above.
- mov Flag,0 ;Assume no growth
- call Delay ;Wait for next Vert retrace
- call Dowindow ;Draw window
- cmp Explode,0 ;Explode?
- je A5 ;No
- call Gensnd ;Make a sound
- mov al,Row1 ;Get current upper row
- cmp al,Urow ;= upper row?
- je A1 ;Yes
- dec Row1 ;Grow up
- or Flag,1 ;=> growth
- A1: mov al,Row2 ;Get current lower row
- cmp al,Lrow ;= lower row?
- je A2 ;Yes
- inc Row2 ;Grow down
- or Flag,1 ;=> growth
- A2: mov al,Col1 ;Get current left column
- cmp al,Lcol ;= left column?
- je A3 ;Yes
- dec Col1 ;Grow left
- or Flag,1 ;=> growth
- A3: mov al,Col2 ;Get current right column
- cmp al,Rcol ;= right column?
- je A4 ;Yes
- inc Col2 ;Grow right
- or Flag,1 ;=> growth
- A4: cmp Flag,0 ;Was there growth?
- je A5 ;No
- jmp Grow ;and do next growth
-
- A5: in al,61h ;Disable speaker
- and al,0FCh
- out 61h,al
- mov Freq,Period ;Reset period for next time
- cmp Shadow,0 ;Make a shadow?
- je A6 ;No
- mov al,Lcol
- sub al,2
- mov Col1,al
- mov al,Urow
- inc al
- mov Row1,al
- mov al,Lrow
- sub al,Urow
- mov Rows,al
- call Findmem ;Find offset of shadow
- mov ah,0 ;Set attr for black on black
- D2: push di
- stosw
- stosw
- pop di
- add di,160
- dec Rows
- jne D2
- mov ch,0
- mov cl,Rcol
- sub cl,Lcol
- call Dorow
- A6: jmp Exit
-
- Dowindow: ;Find offset to upper left corner of current box.
- call Findmem ;Find offset to start of window
- push di ;Save start position
- mov al,Row2 ;Get rows to do
- sub al,Row1
- inc al ;= rows to do
- cmp al,1 ;At least 2 rows?
- ja B0 ;Yes
- mov al,2 ;No, set for 2 Rows
- B0: mov Rows,al ;Save it
- mov ch,0 ;Get current width-1 in cx
- mov cl,Col2
- sub cl,Col1
- cmp cl,2 ;Aty least 3 columns wide?
- ja Dotop ;Yes
- inc Col2 ;No, adjust columns
- dec Col1
- pop di
- jmp Dowindow ;and recompute
- Dotop: ;Do top of box.
- push cx ;Save width
- mov al,Frame ;Get frame type
- mov ah,9 ;6 bytes/frame type in Table
- mul ah ;Offset to frame chars
- mov bx,Table ;Point to frame char table
- add bx,ax ;Point to border char type
- mov ah,Attr ;Get attribute (color)
- call Dorow ;Do the row
- dec Rows ;=rows left to do
- cmp Rows,1 ;=1?
- je Dobottom ;Yes, skip sides of box
- Dosides: ;Do sides of box.
- pop cx ;Get width-1
- pop di ;Get start position
- add di,160 ;Next row
- push di
- push cx ;Save for next time
- push bx ;Save place in table
- call Dorow ;Do the row
- pop dx ;Get 1st middle char address
- dec Rows ;=rows left to do
- cmp Rows,1 ;=1?
- je Dobottom ;Yes
- mov bx,dx ;1st side char address in bx
- jmp Dosides ;and do next row
- Dobottom: ;Do bottom of box.
- pop cx ;Get width-1
- pop di
- add di,160 ;Next row
- call Dorow ;Do the row
- ret ;and return
-
- Dorow: ;Do a row on the screen.
- mov al,[bx] ;Get upper left char
- stosw ;Save in video memory
- inc bx ;Next char
- mov al,[bx] ;Get middle chars
- D1: stosw ;Save to video memory
- loop D1 ;Do all middle chars
- inc bx ;Right char
- mov al,[bx] ;Get right char
- stosw ;Save to video memory
- inc bx
- ret ;and return
-
- Findmem: ;Find the offset of the current Row1,Col1
- mov al,Row1 ;Get current row
- dec al ;Since rows start with 1
- mov ah,160 ;bytes/row
- mul ah ;Offset to start of row
- mov di,ax ;in di
- mov ah,0 ;Get current left column in ax
- mov al,Col1
- dec al ;Since cols start with 1
- shl ax,1 ;Multiply by 2, since 2 bytes/char
- add di,ax ;Add column offset
- ret
-
- Delay: ;Wait for the next vertical retrace.
- mov dx,3DAh ;Video status port
- C0: in al,dx ;Get status
- test al,8 ;Vertical retrace?
- jne C0 ;Yes, wait till done
- C1: in al,dx ;Get status
- test al,8 ;Vertical retrace?
- je C1 ;No, wait for retrace
- ret ;and return
-
- Gensnd: ;Make an increasing pitch sound as window grows.
- mov al,0B6h ;Let the timer know we want to program it
- out 43h,al
- mov ax,Freq ;Send low then high byte to timer
- push ax
- out 42h,al
- mov al,ah
- out 42h,al
- pop ax
- sub ax,20
- mov Freq,ax
- ret
-